import Request_method

class test_case():

    def __init__(self,record=[]):

        self.record = record

        self.result_final = []



    def case1(self):

        for i in range(len(self.record)):


            path = '/mayson/v_1_1/intelligent_recommendation'

            data = {
                "userGuid": "1562317736217",
                "serialNumber": "1562317736217",
                "patientName": "tester",
                "doctorGuid": "0210497",
                "doctorName": "测试医生",
                "admissionTime": "2018-12-12",
                "inpatientDepartment": "心脏科",
                "pageSource": "2",
                "requestSource": "",
                "patientInfo": {
                    "pregnancyStatus": "0",
                    "gender": "1",
                    "age": "19",
                    "maritalStatus": "1",
                    "ageType": "岁"
                },
                "physicalSign": {
                    "bodyTempr": "",
                    "heartRate": "",
                    "lowBldPress": "",
                    "highBldPress": ""
                },
                "definiteDiagnosis": [],
                "progressNoteList": [{
                    "recordTime": "",
                    "doctorGuid": "2222",
                    "messageList": [{
                        "value": self.record[i]['主诉'],
                        "key": "主诉"
                    }, {
                        "value": "",
                        "key": "诊断依据及鉴别诊断"
                    }, {
                        "value": "",
                        "key": "现病史"
                    }, {
                        "value": "",
                        "key": "既往史"
                    }, {
                        "value": "急性心肌梗死",
                        "key": "主诊断"
                    }, {
                        "value": "急性心肌梗死",
                        "key": "出院诊断"
                    }, {
                        "value": "",
                        "key": "辅助检查"
                    }],
                    "msgType": "2",
                    "progressType": "10",
                    "progressGuid": "22222"
                }],
                "deleteProgressNoteList": [{
                    "doctorGid": "",
                    "progressType": "10",
                    "progressGuid": "",
                    "recordTime": ""
                }],
                "labTestList": [],
                "examinationList": [],
                "newTestList": [],
                "operationRecord": {},
                "prescriptions": {
                    "prescriptionNumber": "",
                    "drugList": [{
                        "drugId": "",
                        "specification": "",
                        "dosage": "",
                        "frequency": "",
                        "drugName": "",
                        "pathway": "",
                        "unit": ""
                    }],
                    "recordTime": ""
                },
                "currentDiseaseName": "",
                "medicalOrders": [{
                    "orderCreateTime": self.record[i]['医嘱创建时间'],
                    "status": 1,
                    "orderContent": self.record[i]['手术名称'],
                    "doctorGuid": "0000012061",
                    "sample": "",
                    "frequency": "",
                    "id": 438947,
                    "unit": "ml",
                    "incisionType": "",
                    "uuid": "1294-20778",
                    "orderCode": "2136",
                    "recordId": 20778,
                    "orderType": "6",
                    "specification": "",
                    "anesthesia": "",
                    "stopTime": self.record[i]['手术停止时间'],
                    "operationType": "4",
                    "orderClass": 1,
                    "customerId": 1294,
                    "pathway": "",
                    "orderId": "1562668327867",
                    "executeTime": self.record[i]['手术开始时间'],
                    "dosageform": "",
                    "description": "",
                    "preoperativeDiagnose": "",
                    "orderFlag": 1,
                    "level": "",
                    "timelinessFlag": 1,
                    "position": "",
                    "dosage": "50"
                }],

            }

            url = "http://profile.huimeionline.com/cdss"

            headers = {

                "Content-Type": "application/json;charset=UTF-8",
                "Huimei_id": "7195F12825788F09375C2DB1E922F108"
            }


            send = Request_method.send(url,path,data,headers)

            response = str(send.post())

            if self.record[i]['断言'] in response :

                result_list = [self.record[i]['主诉'],self.record[i]['医嘱创建时间'],self.record[i]['手术名称'],self.record[i]['手术停止时间'],self.record[i]['手术开始时间'],self.record[i]['断言'],
                               url+path,str(data),'通过',''
                               ]
            elif self.record[i]['断言'] not in response:
                result_list = [self.record[i]['主诉'], self.record[i]['医嘱创建时间'], self.record[i]['手术名称'],
                               self.record[i]['手术停止时间'], self.record[i]['手术开始时间'], self.record[i]['断言'],
                               url + path, str(data), '失败', response
                               ]

            self.result_final.append(result_list)
            print(self.record[i]['断言'])
        print(self.result_final)

        return self.result_final
